﻿import Vue from "vue";
//返回数据
//如果 是null 返回 ”“
Vue.filter("if_null", function (value) {
     if (value == null && value == undefined) return " "
     else return value
 })

//img_address
Vue.filter("img_address", function (value) {

    return "http://wx.yizhiweimeng.com/static/" + value
})

//up_load_img
Vue.filter("img_address", function (value) {
    return "http://wx.yizhiweimeng.com/static/audio/" + value
})

//judge_and_add_Base
Vue.filter("judge_and_add_Base", function (value) {
    if(value == null || value==undefined){
      return;
    }
    if (~value.indexOf("https") || ~value.indexOf("http")) {
        return value
    } else {
        return "http://wx.yizhiweimeng.com/static/" + value
    }
})

//wish progress img
Vue.filter("wish_user_img_Base", function (value) {
  if (~value.indexOf("https") || ~value.indexOf("http")) {
    return value
  } else {
    return "http://wx.yizhiweimeng.com/static/" + value
  }
})

//img_show_base
Vue.filter("img_show_base", function (value) {
    if (value == "" || value == null || value == undefined) {
        return "https://wx.yizhiweimeng.com/yizhiweimen/static/img/logo_2.png"
    } else {
        if (~value.indexOf("http")) {
            return  value
        } else {
            return "https://wx.yizhiweimeng.com/yizhiweimen/static/" + value
        }
    }
})

Vue.filter("rank_index_img", function (value) {
  if (value == "" || value == null || value == undefined) {
    return "https://wx.yizhiweimeng.com/yizhiweimen/static/img/logo_2.png"
  } else {
    if (~value.indexOf("http")) {
      return  value
    } else {
      return "https://wx.yizhiweimeng.com" + value
    }
  }
})


//Exchange_my_g
Vue.filter("Exchange_my_g", function (value) {
  // if(typeof(value) == "null"){
  //   console.log("null");
  //   value = false;
  // }

  if (!!value===false||value==null) {
    // console.log("falsejjjjjjjjjjjjj");
    // alert(value)
    // return "https://wx.yizhiweimeng.com/yizhiweimen/static/img/logo_2.png"
    return "fuck"
  } else {
    if (~value.indexOf("http")) {
      return value
    } else {
      return "https://wx.yizhiweimeng.com" + value
    }

  }
})

//img_show_base
Vue.filter("new_img_show_base", function (value) {
    if (!!value===false) {

        // return "https://wx.yizhiweimeng.com/yizhiweimen/static/img/logo_2.png"
      return ""
    } else {
      // console.log("true");
        if (~value.indexOf("http")) {
            return value
        } else {
            return "https://wx.yizhiweimeng.com" + value
        }

    }
})

//active
Vue.filter("new_img_show_Act", function (value) {
    if (value == "" || value == null || value == undefined) {
        return "https://wx.yizhiweimeng.com/yizhiweimen/static/static/img/logo_2.png"
    } else {
        if (~value.indexOf("http")) {
            return value
        } else {
            return "https://wx.yizhiweimeng.com" + value
        }

    }
})

Vue.filter("format_date", function (value, type) {
    function addZero(val){
        if (val < 10) {
            return "0" + val;
        } else {
            return val;
        }
    }
    var dataTime = "";
    var data = new Date();
    data.setTime(value);
    var year = data.getFullYear();
    var month = addZero(data.getMonth() + 1);
    var day = addZero(data.getDate());
    var hour = addZero(data.getHours());
    var minute = addZero(data.getMinutes());
    var second = addZero(data.getSeconds());
    if (type == "YMD") {
        dataTime = year + "-" + month + "-" + day;
    } else if (type == "YMDHMS") {
        dataTime = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
    } else if (type == "HMS") {
        dataTime = hour + ":" + minute + ":" + second;
    } else if (type == "YM") {
        dataTime = year + "-" + month;

    } else {
        dataTime = year + "-" + month + "-" + day;
    }
    // console.log("data)time")
    // console.log(dataTime)
    return dataTime;//将格式化后的字符串输出到前端显示
});

//filter 冒险卡 图片 ， 隔开
Vue.filter("ad_user_img_f", function (value) {
    if (value == null || value == "" || value == undefined) {
        return "https://wx.yizhiweimeng.com/yizhiweimen/static/static/img/logo_2.png"
    }
    let x = value.split(",")
    return "https://wx.yizhiweimeng.com" + x[0]
})

//filter 电话添加
Vue.filter("add_phone", function (value) {
    if(value == null || value == "" || value == undefined) {
        return ""
    }
    //let x = value.split(",")
    return "tel:" + value
})

//rank_act_voice
Vue.filter("rank_act_voice", function (value) {
  try{
    if(value == null || value == "" || value == undefined) {
      return false
    }
  }catch(e){
   console.log(e)
  }

  //let x = value.split(",")
  return value
})

//user_index_card_filter
Vue.filter("user_index_card_filter", function (value) {
  try{
    if(value == null || value == "" || value == undefined) {
      return false
    }
  }catch(e){
    console.log(e)
  }

  //let x = value.split(",")
  return "https://wx.yizhiweimeng.com/yizhiweimen/image/"+value;
})



Vue.filter("getFullYear", function (value) {
  console.log("value___________")
   console.log(value)

  //let x = value.split(",")
  return value.getFullYear
})
